package org.example.admin.service;

import org.example.common.utils.CommonUtil;
import org.example.db.entity.RolePermission;
import org.example.security.service.RolePermissionService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

@Service
public class AdminRolePermissionService {

    RolePermissionService rolePermissionService;

    public AdminRolePermissionService(RolePermissionService rolePermissionService) {
        this.rolePermissionService = rolePermissionService;
    }

    public void addRolePermission(Long roleId, Long permissionId){

        int count = rolePermissionService.addRolePermission(roleId, permissionId);
        CommonUtil.isSqlExcute(count);
    }

    public List<RolePermission> getRolePermissions(Long roleId){
        List<RolePermission> assignedPermissions = null;
        assignedPermissions = rolePermissionService.getRolePermission(roleId);

        return assignedPermissions;
    }

    public void deletePermission(Long roleId){
        rolePermissionService.deletePermissions(roleId);
    }
}
